angular.module('zonaApp').service('zonaServices', function($http){
	
	$http.defaults.useXDomain = true;

	
	var headers = {
			'Access-Control-Allow-Origin' : '*',
			'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT',
			'Access-Control-Allow-Headers' : 'Content-Type, Accept, X-Requested-With',
			'Content-Type': 'application/json',
			'Accept': 'application/json'
		};
	
	this.sendGet = function(urlEndPoint,success,error){
		
		$http({
		  url:urlEndPoint,
		  method: 'GET',
		  headers:headers
	    }).then(
	    		function(response){
	    			success(response);
	    		},
	    		function(response){
	    			error(response);
	    		}
	    );
		
	}
	
	this.sendPost = function(json,urlEndPoint,success,error){
			
			$http({
			  url:urlEndPoint,
			  method: 'POST',
			  data: json,
			  headers:headers
		    }).then(
		    		function(response){
		    			success(response);
		    		},
		    		function(response){
		    			error(response);
		    		}
		    );
			
		}
	
		this.sendPut = function(json,urlEndPoint,success,error){
				
				$http({
				  url:urlEndPoint,
				  method: 'PUT',
				  headers: headers,
			  data: json
		    }).then(
		    		function(response){
		    			success(response);
		    		},
		    		function(response){
		    			error(response);
		    		}
		    );
			
	}
	
});